<%@ page language="java" pageEncoding="UTF-8" %>
<!doctype html>
<html lang="zh-CN">
<head>
    <%@include file="/WEB-INF/views/commons/common.jsp" %>
    <link rel="stylesheet" type="text/css" href="${base_href}/static/ui-frame/bootstrap/3.3.5/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css"
          href="${base_href}/static/ui-frame/bootstrap-dialog3/css/bootstrap-dialog.css">
    <link rel="stylesheet" type="text/css"
          href="${base_href}/static/ui-frame/validation-engine/validationEngine.jquery.css">
    <link rel="stylesheet" type="text/css"
          href="${base_href}/static/ui-frame/jquery-easyui/1.4.3/themes/metro/easyui.css">
    <link rel="stylesheet" type="text/css"
          href="${base_href}/static/ui-frame/font-awesome/4.3.0/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="${base_href}/static/ui-frame/bootstrap/3.3.5/css/build.css">
    <link rel="stylesheet" type="text/css" href="${base_href}/static/ui-frame/webuploader/0.1.5/webuploader.css">
    <link rel="stylesheet" type="text/css" href="${base_href}/static/ui-frame/viewer/viewer.css">
    <link rel="stylesheet" type="text/css" href="${base_href}//static/ui-frame/ztree-v3/css/zTreeStyle/zTreeStyle.css">

    <link rel="stylesheet" type="text/css" href="${base_href}/static/css/search-theme.css">
    <link rel="stylesheet" type="text/css" href="${base_href}/static/css/form-theme.css">

    <link rel="stylesheet" type="text/css" href="${base_href}/static/ui-frame/layui-v2.3.0/layui/css/layui.css">

    <title>疑问详细信息</title>
</head>
<body data-spy="scroll" data-target="#myScrollspy" data-offset="350">


<div class="main-wrap">

    <!-- 工具条 start-->
    <div class="container-fluid form-body-header">
        <div class="container">
            <div class="row tool-bar">
                <div class="col-xs-12">
                    <button type="button" class="btn btn-sm tool-btn" id="saveBtn">保存题目</button>
                </div>
            </div>
        </div>
    </div>
    <!-- 工具条 end-->

    <!-- 表单 start-->
    <div class="container-fluid">
        <form id="form">
            <input type="hidden" name="question.id" value="${form.question.id }"/>
            <input type="hidden" name="question.quesSource" value="2"/>

            <div class="container form-body-div">
                <div class="row text-center title-body" id="baseinfo">
                    疑问详细信息<br/>
                </div>

                <div class="row pannel-title">
                    <span>基本信息</span> <a href="javascript:void(0);" class="hide-next-btn">收起</a>
                </div>
                <div class="row pannel-body">
                    <table class="form-table">
                        <tr>
                            <th class="col-xs-2 ">关联题目</th>
                            <td class="col-xs-10" colspan="3">
                                <input type="hidden" name="question.relationId" value="${form.question.relationId}"/>
                                <input type="text" class="form-control" readonly="readonly"
                                       name="question.relationCode" value="${form.question.relationCode}"
                                       placeholder="如果存在关联书本题目请选择"/>
                            </td>
                        </tr>

                        <tr>
                            <th class="col-xs-2 ">题目信息</th>
                            <td class="col-xs-10" colspan="3">
									<textarea class="form-control validate[required,maxSize[1000]]"
                                              data-errormessage-value-missing="请填写题目信息"
                                              data-errormessage-range-overflow="题目信息长度不能超过1000个字" rows="5"
                                              name="question.question"
                                              placeholder="请填写题目信息">${form.question.question}</textarea>
                                <button type="button" class="layui-btn" id="questionUpload">
                                    <i class="layui-icon">&#xe67c;</i>上传题目图片
                                </button>
                            </td>
                        </tr>
                        <tr>
                            <th class="col-xs-2 ">答案解析</th>
                            <td class="col-xs-10" colspan="3">
									<textarea class="form-control validate[maxSize[1000]]"
                                              data-errormessage-value-missing="请填写答案解析"
                                              data-errormessage-range-overflow="题目信息长度不能超过1000个字" rows="5"
                                              name="question.analysis"
                                              placeholder="请填写答案解析">${form.question.analysis}</textarea>
                                <button type="button" class="layui-btn" id="analysisUpload">
                                    <i class="layui-icon">&#xe67c;</i>上传解析图片
                                </button>
                            </td>
                        </tr>
                    </table>
                </div>

            </div>
        </form>
    </div>
    <!-- 表单 end-->

</div>
<script type="text/javascript" src="${base_href}/static/ui-frame/jquery/1.11.3/jquery.js"></script>
<script type="text/javascript" src="${base_href}/static/ui-frame/bootstrap/3.3.5/js/bootstrap.js"></script>
<script type="text/javascript" src="${base_href}/static/ui-frame/bootstrap-dialog3/js/bootstrap-dialog.js"></script>
<script type="text/javascript"
        src="${base_href}/static/ui-frame/validation-engine/jquery.validationEngine-zh_CN.js"></script>
<script type="text/javascript" src="${base_href}/static/ui-frame/validation-engine/jquery.validationEngine.js"></script>
<script type="text/javascript" src="${base_href}/static/ui-frame/My97DatePicker/WdatePicker.js"></script>

<script type="text/javascript" src="${base_href}/static/ui-frame/ztree-v3/js/jquery.ztree.all-3.5.min.js"></script>
<script type="text/javascript" src="${base_href}/static/support/paper/outline-tree.js"></script>
<script type="text/javascript" src="${base_href}/static/ui-frame/layer/layer.js"></script>
<script type="text/javascript" src="${base_href}/static/ui-frame/layui-v2.3.0/layui/layui.js"></script>
<script type="text/javascript" src="${base_href}/static/support/question/question-attach-edit.js"></script>

<script type="text/javascript">
    $(function () {
        $('#form').validationEngine('attach', {
            maxErrorsPerField: 1,
            scroll: false,
            validationEventTrigger: "keyup blur change focus",
            ValidateNoneVisibleFields: true,//验证隐藏域
            promptPosition: "topRight" //验证弹出框的位置，topRight,topLeft,bottomRight,bottomLeft,centerRight,centerLeft,inline
        });

        $("#saveBtn").click(function () {
            if ($("input[name='paperName']").validationEngine('validate')) {
                var quesType = $("select[name='question.quesType']").val();
                if (quesType != 2) {
                    $("textarea[name='question.stem']").val("");
                }
                return $.post(basePath + "/question/saveQuestion.json", $("#form").serialize(), function () {
                    BootstrapDialog.show({
                        title: "提示框",
                        message: "保存成功",
                        buttons: [{
                            label: "确认",
                            action: function (dialog) {
                                dialog.close();
                            }
                        }]
                    });
                }, 'json');
            }
        });

        //初始化大纲
        OutlineApp.Tree.selectOutLine({
            multi: false,
            selectData: new Array(),
            currentTreeId: "treeDemo",
            selectType: "radio"
        });


        $("input[name='question.relationCode']").click(function () {
            chooseRelation();
        });

        function chooseRelation() {
            var url = basePath + "/questionList/listAskPage.html";
            layer.open({
                type: 2,
                title: '关联题目选择页',
                shadeClose: true,
                shade: 0.8,
                area: ['90%', '90%'],
                content: url //iframe的url
            })
        }
    });

    function setRelation(relationId, relationCode) {
        $("input[name='question.relationId']").val(relationId);
        $("input[name='question.relationCode']").val(relationCode);
        layer.msg("关联成功");
    }
</script>
</body>
</html>
